package unv.esiag.uchiha.operations;

import java.io.Serializable;

public class Operation implements Serializable{
	private static final long serialVersionUID = 1L;
	
	public static final int TARGET_CACHE = 0;
	public static final int TARGET_TOPIC = 1;
	
	public static final int TYPE_SETSUBSCRIBER = 0;
	public static final int TYPE_BOOTSTRAP = 1;
	public static final int TYPE_CREATE = 2;
	public static final int TYPE_STOP = 3;
	
	public static final int SOURCE_USER = 0;
	public static final int SOURCE_INSTANCE = 1;
	
	private int target;
	private int type;
	private boolean replicate = false;
	private int source;
	private DataObject data;
	public Operation(int target, int type, DataObject data) {
		this.target = target;
		this.type = type;
		this.data = data;
	}
	public int getSource() {
		return source;
	}
	public void setSource(int source) {
		this.source = source;
	}
	public void setReplicate(boolean replicate) {
		this.replicate = replicate;
	}
	public boolean isReplicate() {
		return replicate;
	}
	public int getTarget() {
		return target;
	}
	public void setTarget(int target) {
		this.target = target;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public DataObject getData() {
		return data;
	}
	public void setData(DataObject data) {
		this.data = data;
	}

	public String toString() {
		return "target(" + this.target + ") type(" + this.type + ") source(" + this.source + ") " + this.data.toString();
	}
	public Operation clone(){
		Operation op = new Operation(getTarget(), getType(), this.data.clone());
		op.setReplicate(isReplicate());
		return op;
	}
}
